package defectsim.resources;

import javax.vecmath.Vector2d;

import defectsim.SimulationEnvironment;
import defectsim.agents.DefectAgent;
import defectsim.agents.EdgeDislocation;

public class DragForce extends DefectResource implements Force{
	private ForceType fType;

	private SimulationEnvironment env = SimulationEnvironment.getInstance();

	private static DragForce _instance = null;

	static public DragForce getInstance() {
		if(_instance == null) {
			_instance = new DragForce();
		}
		return _instance;
	}
	
	// Drag force class is singleton
	private DragForce(){
		fType = ForceType.Drag;
	}
	
	public void initialize(){
		
	}
	
	public Vector2d compute(DefectAgent da) {
		double v = 0;
		if (da instanceof EdgeDislocation){
			EdgeDislocation d = (EdgeDislocation)da;
			v = d.getVelocity().x;
		}
		return new Vector2d(v * env.getMaterial().getDampingCoefficientForGlide(), 0.0);
	}
	
	@Override
	public ForceType getForceType() {
		return fType;
	}

	@Override
	public void update() {

	}

	@Override
	public Vector2d getStress(DefectAgent da) {
		// TODO Auto-generated method stub
		return null;
	}
}
